<template>
    <div class="breadcrumb">
        <span class="breadcrumb-title">{{ newTitle }}</span>
        <span class="breadcrumb-description">{{ description }}</span>
        <slot></slot>
    </div>
</template>

<script>
export default {
    name: 'Breadcrumb',
    props: {
        title: {
            type: String,
            required: true,
        },
        description: {
            type: String,
            default: d => {
                if (d) {
                    const length = Array.from(d)
                    return length > 20 ? d.substr(0, 20) + '...' : d
                } else {
                    return ''
                }
            },
        },
    },
    computed: {
        newTitle() {
            if (this.$store.state.userInfo.roleCode === 2 && this.$route.name === 'statisticsPro') {
                return '统计分析(市/县 (市、区))'
            }
            return this.title
        },
    },
}
</script>

<style lang="scss" scoped>
.breadcrumb {
    height: 60px;
    padding: 18px;
    color: #00152a;
    font-size: 18px;
    display: flex;
    align-items: center;
    font-family: PingFangSC, PingFangSC-Semibold;
    background-color: #fff;
    box-shadow: 0px 0px 6px 0px #e0e0e0;
    margin: 0 0 20px 1px;
    button {
        font-size: 14px;
        font-family: AlibabaPuHuiTiR;
    }

    &-title {
        font-weight: 600;
        margin-left: 26px;
        line-height: 17px;
    }
    &-description {
        width: 363px;
        margin-left: 20px;
        font-size: 12px;
        font-family: PingFangSC, PingFangSC-Light;
        font-weight: 300;
        text-align: left;
        line-height: 17px;
        letter-spacing: 0px;
        overflow: hidden;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        white-space: nowrap;
    }
}
</style>
